cx5_sources = files(
  'cx5_abi.cpp',
  'cx5_card.cpp',
  'cx5_om.cpp',
  'cx5_port.cpp',
) + interface_sources

include_dirs += include_directories('../../../chip')
include_dirs += include_directories('../../../internal')

libcx5_static = static_library(
  'cx5',
  cx5_sources,
  include_directories: include_dirs + mellanox_interface_inc,
  dependencies: [dev_deps, libncsi_over_mctp_dep, libmctp_dep, libimu_dep],
  install: false,
)

libcx5 = shared_library(
  'cx5',
  include_directories: include_dirs + mellanox_interface_inc,
  name_prefix: 'lib',
  name_suffix: 'so',
  install: true,
  install_dir: drivers_install_dir,
  link_whole: [libcx5_static],
)
if build_tests
  cx5_dep = declare_dependency(
    include_directories: include_dirs + mellanox_interface_inc,
    link_with: libcx5_static,
    dependencies: [
      libmcpp_deps,
      libncsi_over_mctp_dep,
      libmctp_dep,
      libimu_dep,
    ],
  )
endif
if build_tests and meson_build
  custom_target(
    'copy_libcx5',
    output: 'copy_libcx5',
    command: ['cp', libcx5.full_path(), drivers_install_dir],
    depends: libcx5,
    build_by_default: true,
  )
endif